Version:0.9
StartHTML:0000000105
EndHTML:0000070756
StartFragment:0000001215
EndFragment:0000070740
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>mikroElektonika</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="generator" content="SynEdit HTML exporter" />
<style type="text/css">
<!--
body { color: #000000; background-color: #FFFFFF; }
.cpp1-assembler { color: #FF0000; font-weight: bold; }
.cpp1-binary { color: #008000; }
.cpp1-character { color: #FFFF00; }
.cpp1-comment { color: #008000; font-style: italic; }
.cpp1-float { color: #0000FF; }
.cpp1-hexadecimal { color: #008080; }
.cpp1-identifier { color: #C0C0C0; }
.cpp1-illegalchar { color: #FF0000; }
.cpp1-number { color: #008000; }
.cpp1-octal { color: #008000; }
.cpp1-preprocessor { color: #808000; font-style: italic; }
.cpp1-reservedword { color: #008080; font-weight: bold; }
.cpp1-space { color: #000000; }
.cpp1-string { color: #FFFF00; }
.cpp1-symbol { color: #808080; }
-->
</style>
</head>
<body>
<!--StartFragment--><pre><code><span class="cpp1-comment">/*
 * Project name:

 * Copyright:

 * Description:

 * Test configuration:

 * NOTES:
     - .
*/
//Includes
</span><span class="cpp1-preprocessor">#include &quot;TMRxCOnfig.h&quot;
#include &quot;config.h&quot;
#include &quot;sine.h&quot;

#define TRUE 1
#define FALSE 0


</span><span class="cpp1-comment">//Define LED Ouputs
</span><span class="cpp1-preprocessor">#define LED1 PORTB.F1
#define LED2 PORTB.F2
#define LED3 PORTB.F3
#define LED4 PORTB.F4
#define LED5 PORTB.F6
#define TESTPIN PORTB.F0
#define TESTPIN2 PORTA.F3

</span><span class="cpp1-comment">//Direction Values
</span><span class="cpp1-preprocessor">#define NODIR     0
#define LEFTDIR   1
#define RIGHTDIR  2

</span><span class="cpp1-comment">//Speed Values
</span><span class="cpp1-preprocessor">#define MINSPEED	5
#define DRIVESPEED 	40


</span><span class="cpp1-reservedword">enum</span><span class="cpp1-space"> </span><span class="cpp1-identifier">Modes</span><span class="cpp1-space"> </span><span class="cpp1-symbol">{
</span><span class="cpp1-identifier">INC</span><span class="cpp1-symbol">,
</span><span class="cpp1-identifier">DEC</span><span class="cpp1-symbol">,
</span><span class="cpp1-identifier">CONST</span><span class="cpp1-symbol">,
</span><span class="cpp1-identifier">ZERO
</span><span class="cpp1-symbol">}</span><span class="cpp1-identifier">RemMode</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-identifier">GasMode</span><span class="cpp1-symbol">;

</span><span class="cpp1-reservedword">enum</span><span class="cpp1-space"> </span><span class="cpp1-identifier">States</span><span class="cpp1-space">  </span><span class="cpp1-symbol">{
</span><span class="cpp1-identifier">DRIVING</span><span class="cpp1-symbol">,
</span><span class="cpp1-identifier">BREAKING</span><span class="cpp1-symbol">,
</span><span class="cpp1-identifier">STANDSTILL</span><span class="cpp1-symbol">,
</span><span class="cpp1-identifier">ACC
</span><span class="cpp1-symbol">}</span><span class="cpp1-identifier">programState</span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">ACC</span><span class="cpp1-symbol">;


</span><span class="cpp1-comment">//------------Global Variables---------------------//
</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">unsigned</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">short</span><span class="cpp1-space"> </span><span class="cpp1-identifier">iSpeed</span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">,</span><span class="cpp1-identifier">BreakON</span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">FALSE</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-identifier">tmr1Overflow</span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">FALSE</span><span class="cpp1-symbol">,</span><span class="cpp1-identifier">tmr0Overflow</span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">FALSE</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-identifier">getNewDuty</span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">TRUE</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-identifier">pwmOn</span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">FALSE</span><span class="cpp1-symbol">,</span><span class="cpp1-identifier">timerValue</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-identifier">readReady</span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">FALSE</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-identifier">incReady</span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">FALSE</span><span class="cpp1-symbol">;
</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">int</span><span class="cpp1-space"> </span><span class="cpp1-identifier">n_position</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-number">0</span><span class="cpp1-symbol">;
</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">unsigned</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">short</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">int</span><span class="cpp1-space"> </span><span class="cpp1-identifier">PWMSignal</span><span class="cpp1-symbol">[</span><span class="cpp1-number">3</span><span class="cpp1-symbol">];</span><span class="cpp1-space">                    </span><span class="cpp1-comment">// Create a array with 3 elements for the pwm signals
</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">double</span><span class="cpp1-space"> </span><span class="cpp1-identifier">tPeriod</span><span class="cpp1-symbol">,</span><span class="cpp1-identifier">factor</span><span class="cpp1-symbol">,</span><span class="cpp1-identifier">tcp</span><span class="cpp1-symbol">,</span><span class="cpp1-identifier">t1Freq</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-identifier">t0Freq</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-float">7812.50</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-identifier">acceleration</span><span class="cpp1-symbol">=</span><span class="cpp1-float">10.00</span><span class="cpp1-symbol">;
</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">double</span><span class="cpp1-space">  </span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-identifier">MINSPEED</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-identifier">newSpeed</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-identifier">DRIVESPEED</span><span class="cpp1-symbol">,</span><span class="cpp1-identifier">currentRem</span><span class="cpp1-symbol">=</span><span class="cpp1-float">0.00</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-identifier">newRem</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-float">0.00</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-identifier">unitstep</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-identifier">unitTime</span><span class="cpp1-symbol">,</span><span class="cpp1-identifier">tmp</span><span class="cpp1-space"> </span><span class="cpp1-symbol">;
</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">unsigned</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">int</span><span class="cpp1-space"> </span><span class="cpp1-identifier">h_value</span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-identifier">TIMER1V</span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-identifier">iDirection</span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">	
</span><span class="cpp1-comment">//Read AN Input Values
</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">unsigned</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">short</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">int</span><span class="cpp1-space"> </span><span class="cpp1-identifier">l_value</span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-identifier">newDirection</span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">NODIR</span><span class="cpp1-symbol">,</span><span class="cpp1-identifier">currentDirection</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-identifier">NODIR</span><span class="cpp1-symbol">;

</span><span class="cpp1-space"> </span><span class="cpp1-comment">// Prototypes
</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">void</span><span class="cpp1-space"> </span><span class="cpp1-identifier">sineWave</span><span class="cpp1-symbol">(</span><span class="cpp1-reservedword">double</span><span class="cpp1-symbol">);
</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">void</span><span class="cpp1-space"> </span><span class="cpp1-identifier">portInit</span><span class="cpp1-symbol">();
</span><span class="cpp1-reservedword">void</span><span class="cpp1-space"> </span><span class="cpp1-identifier">checkControlPanel</span><span class="cpp1-symbol">();
</span><span class="cpp1-reservedword">void</span><span class="cpp1-space"> </span><span class="cpp1-identifier">updateDutyCycle</span><span class="cpp1-symbol">(</span><span class="cpp1-reservedword">unsigned</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">short</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">int</span><span class="cpp1-space"> </span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">unsigned</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">short</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">int</span><span class="cpp1-symbol">);
</span><span class="cpp1-reservedword">double</span><span class="cpp1-space"> </span><span class="cpp1-identifier">getFreqInHz</span><span class="cpp1-symbol">(</span><span class="cpp1-reservedword">unsigned</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">short</span><span class="cpp1-space"> </span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">double</span><span class="cpp1-space"> </span><span class="cpp1-symbol">)</span><span class="cpp1-space"> </span><span class="cpp1-symbol">;
</span><span class="cpp1-reservedword">void</span><span class="cpp1-space"> </span><span class="cpp1-identifier">calcUnitTime</span><span class="cpp1-symbol">(</span><span class="cpp1-reservedword">double</span><span class="cpp1-space"> </span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">double</span><span class="cpp1-space"> </span><span class="cpp1-symbol">);

</span><span class="cpp1-reservedword">void</span><span class="cpp1-space"> </span><span class="cpp1-identifier">initMain</span><span class="cpp1-symbol">()</span><span class="cpp1-space"> </span><span class="cpp1-symbol">{
</span><span class="cpp1-space">  </span><span class="cpp1-comment">// INIT PORT CONFIGURATIONS
</span><span class="cpp1-space">	</span><span class="cpp1-identifier">portInit</span><span class="cpp1-symbol">();

</span><span class="cpp1-space">	</span><span class="cpp1-identifier">sinetableInit</span><span class="cpp1-symbol">();</span><span class="cpp1-space">           </span><span class="cpp1-comment">// Initialize the sinetabel

</span><span class="cpp1-space">	</span><span class="cpp1-identifier">Pwm1_Init</span><span class="cpp1-symbol">(</span><span class="cpp1-number">5000</span><span class="cpp1-symbol">);</span><span class="cpp1-space">          </span><span class="cpp1-comment">//PWM INIt
</span><span class="cpp1-space">	</span><span class="cpp1-identifier">Pwm2_Init</span><span class="cpp1-symbol">(</span><span class="cpp1-number">5000</span><span class="cpp1-symbol">);
</span><span class="cpp1-space">	</span><span class="cpp1-identifier">Pwm3_Init</span><span class="cpp1-symbol">(</span><span class="cpp1-number">5000</span><span class="cpp1-symbol">);

</span><span class="cpp1-space">    </span><span class="cpp1-identifier">Timer1_Init</span><span class="cpp1-symbol">();</span><span class="cpp1-space">           </span><span class="cpp1-comment">//Timer Inits

</span><span class="cpp1-space">    </span><span class="cpp1-identifier">Timer0_OptionReg</span><span class="cpp1-symbol">(</span><span class="cpp1-hexadecimal">0x87</span><span class="cpp1-symbol">);</span><span class="cpp1-space">  </span><span class="cpp1-comment">//0x84
</span><span class="cpp1-space">    </span><span class="cpp1-identifier">calcUnitTime</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">acceleration</span><span class="cpp1-symbol">,</span><span class="cpp1-identifier">t0Freq</span><span class="cpp1-symbol">);
</span><span class="cpp1-space">	</span><span class="cpp1-identifier">Timer0_IE</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">    </span><span class="cpp1-identifier">TMR0</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-identifier">timerValue</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">    
    </span><span class="cpp1-identifier">INTCON</span><span class="cpp1-symbol">.</span><span class="cpp1-identifier">GIE</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;</span><span class="cpp1-space">           </span><span class="cpp1-comment">//Enable Interrupts
</span><span class="cpp1-space">    </span><span class="cpp1-identifier">INTCON</span><span class="cpp1-symbol">.</span><span class="cpp1-identifier">PEIE</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;
</span><span class="cpp1-space"> </span><span class="cpp1-symbol">}

</span><span class="cpp1-reservedword">void</span><span class="cpp1-space"> </span><span class="cpp1-identifier">portInit</span><span class="cpp1-symbol">()
{
</span><span class="cpp1-comment">/*
// NOTES:
//-------------------------
// TRISx BIT = 0 : BIT IS OUTPUT
//  ''  ''   = 1 : BIT IS INPUT
//-------------------------
*/
</span><span class="cpp1-space">   </span><span class="cpp1-comment">//      TRISA = 0b00100111;
</span><span class="cpp1-space">   </span><span class="cpp1-identifier">TRISA</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-binary">0b11110111</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">   </span><span class="cpp1-identifier">PORTA</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-hexadecimal">0x00</span><span class="cpp1-symbol">;
</span><span class="cpp1-space"> 

   </span><span class="cpp1-comment">//TRISB = 0b11000001;
</span><span class="cpp1-space">   </span><span class="cpp1-identifier">TRISB</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-binary">0b10000000</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">   </span><span class="cpp1-identifier">PORTB</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-hexadecimal">0x00</span><span class="cpp1-symbol">;

</span><span class="cpp1-space">   </span><span class="cpp1-identifier">TRISC</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-binary">0b10111001</span><span class="cpp1-symbol">;</span><span class="cpp1-space">      </span><span class="cpp1-comment">// Outputs: RC1 and RC2
</span><span class="cpp1-space">   </span><span class="cpp1-identifier">PORTC</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-hexadecimal">0x00</span><span class="cpp1-symbol">;</span><span class="cpp1-space">            </span><span class="cpp1-comment">// Inputs: RC5
</span><span class="cpp1-symbol">}

</span><span class="cpp1-reservedword">void</span><span class="cpp1-space"> </span><span class="cpp1-identifier">main</span><span class="cpp1-symbol">()</span><span class="cpp1-space"> </span><span class="cpp1-symbol">{
</span><span class="cpp1-space">   </span><span class="cpp1-identifier">ADCON1</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-binary">0b10001101</span><span class="cpp1-symbol">;</span><span class="cpp1-space">  </span><span class="cpp1-comment">// Configure analog inputs and Vref   //Changed
</span><span class="cpp1-space">  </span><span class="cpp1-identifier">initMain</span><span class="cpp1-symbol">();

</span><span class="cpp1-space">  </span><span class="cpp1-reservedword">while</span><span class="cpp1-space"> </span><span class="cpp1-symbol">(</span><span class="cpp1-number">1</span><span class="cpp1-symbol">)
</span><span class="cpp1-space">  </span><span class="cpp1-symbol">{

</span><span class="cpp1-space">	 </span><span class="cpp1-reservedword">switch</span><span class="cpp1-space"> </span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">programState</span><span class="cpp1-symbol">)
</span><span class="cpp1-space">	</span><span class="cpp1-symbol">{</span><span class="cpp1-comment">//preconditions: initial state = default (OFF state) ??
</span><span class="cpp1-space">   
		</span><span class="cpp1-reservedword">case</span><span class="cpp1-space"> </span><span class="cpp1-identifier">ACC</span><span class="cpp1-symbol">:</span><span class="cpp1-space"> 
		</span><span class="cpp1-comment">/* ACCeleration from |fmin| to |freq| in |acc/dec time| seconds
		* PWM's	:ON
		* ACC	:ON
		* Timer0:ON
		* Timer1:ON
		*/
</span><span class="cpp1-space">			
  		   </span><span class="cpp1-comment">//Output: Only Led3 On
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED1</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED2</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED3</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED4</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED5</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			
 
			
			</span><span class="cpp1-reservedword">if</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">tmr1Overflow</span><span class="cpp1-space"> </span><span class="cpp1-symbol">==</span><span class="cpp1-space"> </span><span class="cpp1-identifier">TRUE</span><span class="cpp1-symbol">)
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">{</span><span class="cpp1-comment">//If timer1 overflowed change pwm dutycycles

</span><span class="cpp1-space">				</span><span class="cpp1-identifier">updateDutyCycle</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">newDirection</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-symbol">/</span><span class="cpp1-number">43</span><span class="cpp1-symbol">)*</span><span class="cpp1-number">255</span><span class="cpp1-symbol">);

</span><span class="cpp1-space">				</span><span class="cpp1-identifier">tmr1Overflow</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">FALSE</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">PIE1</span><span class="cpp1-symbol">.</span><span class="cpp1-identifier">TMR1IE</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-number">1</span><span class="cpp1-symbol">;</span><span class="cpp1-space"> </span><span class="cpp1-comment">//Enables TMR1 Interrupt
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">}
</span><span class="cpp1-space">			
			</span><span class="cpp1-identifier">Pwm1_Start</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">Pwm2_Start</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">Pwm3_Start</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">Timer1_IE</span><span class="cpp1-symbol">()</span><span class="cpp1-space"> </span><span class="cpp1-symbol">;
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">Timer1_Start</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">INTCON</span><span class="cpp1-symbol">.</span><span class="cpp1-identifier">PEIE</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			
			
			</span><span class="cpp1-reservedword">if</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">tmr0Overflow</span><span class="cpp1-space"> </span><span class="cpp1-symbol">==</span><span class="cpp1-identifier">TRUE</span><span class="cpp1-symbol">)
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">{</span><span class="cpp1-comment">//unitStep must be already calculated
</span><span class="cpp1-space">				
				</span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-symbol">&lt;</span><span class="cpp1-identifier">newSpeed</span><span class="cpp1-symbol">)</span><span class="cpp1-space"> </span><span class="cpp1-symbol">?(</span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-symbol">+</span><span class="cpp1-identifier">unitStep</span><span class="cpp1-symbol">)</span><span class="cpp1-space"> </span><span class="cpp1-symbol">:</span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">sineWave</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-symbol">);
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">tmr0Overflow</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">FALSE</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">Timer0_IE</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">}
</span><span class="cpp1-space">			
			</span><span class="cpp1-comment">//if speed is |freq| then programState = DRIVING
</span><span class="cpp1-space">			</span><span class="cpp1-reservedword">if</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-space"> </span><span class="cpp1-symbol">&gt;=</span><span class="cpp1-identifier">newSpeed</span><span class="cpp1-symbol">)
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">{
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">programState</span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">DRIVING</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">Timer0_ID</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">}
</span><span class="cpp1-space">			

			</span><span class="cpp1-reservedword">break</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">		</span><span class="cpp1-reservedword">case</span><span class="cpp1-space"> </span><span class="cpp1-identifier">DRIVING</span><span class="cpp1-symbol">:</span><span class="cpp1-space"> 
		</span><span class="cpp1-comment">/* Driving at DRIVINGSPEED : This state is called after ACC
		* PWM's	:ON
		* ACC	:OFF
		* Timer0:OFF
		* Timer1:ON
		*/
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">checkControlPanel</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">			
			</span><span class="cpp1-comment">//Output: Led1, Led3 On
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED1</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED2</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED3</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED4</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED5</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			
			
           
			
			</span><span class="cpp1-reservedword">if</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">tmr1Overflow</span><span class="cpp1-space"> </span><span class="cpp1-symbol">==</span><span class="cpp1-space"> </span><span class="cpp1-identifier">TRUE</span><span class="cpp1-symbol">)
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">{</span><span class="cpp1-comment">//If timer1 overflowed change pwm dutycycles

</span><span class="cpp1-space">				</span><span class="cpp1-identifier">updateDutyCycle</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">newDirection</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-symbol">/</span><span class="cpp1-number">43</span><span class="cpp1-symbol">)*</span><span class="cpp1-number">255</span><span class="cpp1-symbol">);

</span><span class="cpp1-space">				</span><span class="cpp1-identifier">tmr1Overflow</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">FALSE</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">PIE1</span><span class="cpp1-symbol">.</span><span class="cpp1-identifier">TMR1IE</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-number">1</span><span class="cpp1-symbol">;</span><span class="cpp1-space"> </span><span class="cpp1-comment">//Enables TMR1 Interrupt
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">}
</span><span class="cpp1-space">			
			 </span><span class="cpp1-identifier">Pwm1_Start</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">Pwm2_Start</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">Pwm3_Start</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">Timer1_IE</span><span class="cpp1-symbol">()</span><span class="cpp1-space"> </span><span class="cpp1-symbol">;
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">Timer1_Start</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">INTCON</span><span class="cpp1-symbol">.</span><span class="cpp1-identifier">PEIE</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			
			</span><span class="cpp1-comment">//If break=ON then programState = BREAKING
</span><span class="cpp1-space">			</span><span class="cpp1-reservedword">if</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">BreakON</span><span class="cpp1-space"> </span><span class="cpp1-symbol">==</span><span class="cpp1-space"> </span><span class="cpp1-identifier">TRUE</span><span class="cpp1-symbol">)
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">{
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">programState</span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">BREAKING</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">newSpeed</span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-identifier">MINSPEED</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">Timer0_IE</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">}
</span><span class="cpp1-space">			</span><span class="cpp1-reservedword">break</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">		</span><span class="cpp1-reservedword">case</span><span class="cpp1-space"> </span><span class="cpp1-identifier">BREAKING</span><span class="cpp1-space"> </span><span class="cpp1-symbol">:</span><span class="cpp1-space">  
			</span><span class="cpp1-comment">/* Breaking from |fmin| to |freq| in |acc/dec time| seconds
			* PWM's	:ON
			* ACC/DEC	:ON
			* Timer0:ON
			* Timer1:ON
			*/
</span><span class="cpp1-space">			</span><span class="cpp1-comment">//Output: Led2, Led 3 On
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED1</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED2</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED3</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED4</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED5</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			
			
            </span><span class="cpp1-identifier">Pwm1_Start</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">Pwm2_Start</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">Pwm3_Start</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">Timer1_IE</span><span class="cpp1-symbol">()</span><span class="cpp1-space"> </span><span class="cpp1-symbol">;
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">Timer1_Start</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">INTCON</span><span class="cpp1-symbol">.</span><span class="cpp1-identifier">PEIE</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			
			</span><span class="cpp1-reservedword">if</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">tmr1Overflow</span><span class="cpp1-space"> </span><span class="cpp1-symbol">==</span><span class="cpp1-space"> </span><span class="cpp1-identifier">TRUE</span><span class="cpp1-symbol">)
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">{</span><span class="cpp1-comment">//If timer1 overflowed change pwm dutycycles

</span><span class="cpp1-space">				</span><span class="cpp1-identifier">updateDutyCycle</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">newDirection</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-symbol">/</span><span class="cpp1-number">43</span><span class="cpp1-symbol">)*</span><span class="cpp1-number">255</span><span class="cpp1-symbol">);

</span><span class="cpp1-space">				</span><span class="cpp1-identifier">tmr1Overflow</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">FALSE</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">PIE1</span><span class="cpp1-symbol">.</span><span class="cpp1-identifier">TMR1IE</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-number">1</span><span class="cpp1-symbol">;</span><span class="cpp1-space"> </span><span class="cpp1-comment">//Enables TMR1 Interrupt
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">}
</span><span class="cpp1-space">			
			</span><span class="cpp1-identifier">checkControlPanel</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">			</span><span class="cpp1-comment">//If speed == |fmin| &amp;&amp; Break ==OFF then programState ==ACC 
</span><span class="cpp1-space">			
			
			</span><span class="cpp1-reservedword">if</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">tmr0Overflow</span><span class="cpp1-space"> </span><span class="cpp1-symbol">==</span><span class="cpp1-identifier">TRUE</span><span class="cpp1-symbol">)
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">{</span><span class="cpp1-comment">//unitStep must be already calculated
</span><span class="cpp1-space">				
				</span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-symbol">&gt;</span><span class="cpp1-identifier">newSpeed</span><span class="cpp1-symbol">)</span><span class="cpp1-space"> </span><span class="cpp1-symbol">?(</span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-symbol">-</span><span class="cpp1-identifier">unitStep</span><span class="cpp1-symbol">)</span><span class="cpp1-space"> </span><span class="cpp1-symbol">:</span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">sineWave</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-symbol">);
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">tmr0Overflow</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">FALSE</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">Timer0_IE</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">}
</span><span class="cpp1-space">			
			</span><span class="cpp1-comment">//if speed is |freq| then programState = DRIVING
</span><span class="cpp1-space">			</span><span class="cpp1-comment">/* if(currentSpeed &lt;=newSpeed &amp;&amp; BreakON==FALSE)
			{
				programState=STANDSTILL;
				
			} */
</span><span class="cpp1-space">			
			</span><span class="cpp1-reservedword">if</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-space"> </span><span class="cpp1-symbol">&lt;=</span><span class="cpp1-identifier">newSpeed</span><span class="cpp1-symbol">)
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">{
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">programState</span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">STANDSTILL</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">				
			</span><span class="cpp1-symbol">}

</span><span class="cpp1-space">			
			</span><span class="cpp1-reservedword">break</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			
			</span><span class="cpp1-reservedword">case</span><span class="cpp1-space"> </span><span class="cpp1-identifier">STANDSTILL</span><span class="cpp1-symbol">:</span><span class="cpp1-space"> 
			</span><span class="cpp1-comment">/* STANDSTILL at MINSPEED : This state is called after BREAKING
			* PWM's	:OFF
			* ACC	:OFF
			* Timer0:OFF
			* Timer1:ON
			*/
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">checkControlPanel</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">			
			</span><span class="cpp1-comment">//Output: Led1, Led3 On
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED1</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED2</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED3</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED4</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED5</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			
			
            </span><span class="cpp1-identifier">Pwm1_Start</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">Pwm2_Start</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">Pwm3_Start</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">Timer1_IE</span><span class="cpp1-symbol">()</span><span class="cpp1-space"> </span><span class="cpp1-symbol">;
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">Timer1_Start</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">            </span><span class="cpp1-identifier">INTCON</span><span class="cpp1-symbol">.</span><span class="cpp1-identifier">PEIE</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">1</span><span class="cpp1-symbol">;

</span><span class="cpp1-space">			</span><span class="cpp1-reservedword">if</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">tmr1Overflow</span><span class="cpp1-space"> </span><span class="cpp1-symbol">==</span><span class="cpp1-space"> </span><span class="cpp1-identifier">TRUE</span><span class="cpp1-symbol">)
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">{</span><span class="cpp1-comment">//If timer1 overflowed change pwm dutycycles

</span><span class="cpp1-space">				</span><span class="cpp1-identifier">updateDutyCycle</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">newDirection</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-symbol">/</span><span class="cpp1-number">43</span><span class="cpp1-symbol">)*</span><span class="cpp1-number">255</span><span class="cpp1-symbol">);

</span><span class="cpp1-space">				</span><span class="cpp1-identifier">tmr1Overflow</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">FALSE</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">PIE1</span><span class="cpp1-symbol">.</span><span class="cpp1-identifier">TMR1IE</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-number">1</span><span class="cpp1-symbol">;</span><span class="cpp1-space"> </span><span class="cpp1-comment">//Enables TMR1 Interrupt
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">}
</span><span class="cpp1-space">			
			</span><span class="cpp1-comment">//If break=ON then programState = BREAKING
</span><span class="cpp1-space">			</span><span class="cpp1-reservedword">if</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">BreakON</span><span class="cpp1-space"> </span><span class="cpp1-symbol">==</span><span class="cpp1-space"> </span><span class="cpp1-identifier">FALSE</span><span class="cpp1-symbol">)
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">{
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">programState</span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">ACC</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			
				</span><span class="cpp1-identifier">currentSpeed</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-identifier">MINSPEED</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">newSpeed</span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-identifier">DRIVESPEED</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">Timer0_IE</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">			</span><span class="cpp1-symbol">}
</span><span class="cpp1-space">			</span><span class="cpp1-reservedword">break</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">		</span><span class="cpp1-reservedword">default</span><span class="cpp1-symbol">:</span><span class="cpp1-comment">//OFF State

</span><span class="cpp1-space">			</span><span class="cpp1-comment">//Outputs: ALl off
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED1</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED2</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED3</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED4</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-identifier">LED5</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">			</span><span class="cpp1-reservedword">break</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">	</span><span class="cpp1-symbol">}

}
}
</span><span class="cpp1-reservedword">void</span><span class="cpp1-space"> </span><span class="cpp1-identifier">calcUnitTime</span><span class="cpp1-symbol">(</span><span class="cpp1-reservedword">double</span><span class="cpp1-space"> </span><span class="cpp1-identifier">a</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">double</span><span class="cpp1-space"> </span><span class="cpp1-identifier">tmr0Freq</span><span class="cpp1-space"> </span><span class="cpp1-symbol">)
{
</span><span class="cpp1-space">    </span><span class="cpp1-identifier">unitstep</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-float">0.25</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">    </span><span class="cpp1-identifier">unitTime</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-identifier">unitstep</span><span class="cpp1-symbol">/</span><span class="cpp1-identifier">a</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">    </span><span class="cpp1-identifier">tmp</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space">    </span><span class="cpp1-identifier">unitTime</span><span class="cpp1-symbol">*</span><span class="cpp1-identifier">tmr0Freq</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">    </span><span class="cpp1-identifier">timerValue</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-hexadecimal">0xFF</span><span class="cpp1-space"> </span><span class="cpp1-symbol">-</span><span class="cpp1-space"> </span><span class="cpp1-identifier">tmp</span><span class="cpp1-symbol">;
}

</span><span class="cpp1-reservedword">void</span><span class="cpp1-space"> </span><span class="cpp1-identifier">checkControlPanel</span><span class="cpp1-symbol">()
{</span><span class="cpp1-comment">// Preconditions:
// - ADCON be setup accordingly
// - Switches be correctly configured
</span><span class="cpp1-space">  
  </span><span class="cpp1-comment">//Read AN Input Values
</span><span class="cpp1-space">    </span><span class="cpp1-comment">// iSpeed = Adc_Read(0)&gt;&gt;2;
</span><span class="cpp1-space">     </span><span class="cpp1-identifier">iDirection</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-identifier">Adc_Read</span><span class="cpp1-symbol">(</span><span class="cpp1-number">1</span><span class="cpp1-symbol">);
</span><span class="cpp1-space">	</span><span class="cpp1-identifier">BreakON</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> 	</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">iDirection</span><span class="cpp1-symbol">&gt;</span><span class="cpp1-number">255</span><span class="cpp1-symbol">)</span><span class="cpp1-space"> </span><span class="cpp1-symbol">?</span><span class="cpp1-identifier">TRUE</span><span class="cpp1-space"> </span><span class="cpp1-symbol">:</span><span class="cpp1-identifier">FALSE</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">	</span><span class="cpp1-comment">//newSpeed = getFreqInHz(iSpeed,43.00);
</span><span class="cpp1-space">  
</span><span class="cpp1-symbol">}

</span><span class="cpp1-reservedword">double</span><span class="cpp1-space"> </span><span class="cpp1-identifier">getFreqInHz</span><span class="cpp1-symbol">(</span><span class="cpp1-reservedword">unsigned</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">short</span><span class="cpp1-space"> </span><span class="cpp1-identifier">adcSpeed</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">double</span><span class="cpp1-space"> </span><span class="cpp1-identifier">MAXFREQ</span><span class="cpp1-symbol">)
{
</span><span class="cpp1-space">	</span><span class="cpp1-reservedword">double</span><span class="cpp1-space"> </span><span class="cpp1-identifier">freq</span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">	</span><span class="cpp1-reservedword">double</span><span class="cpp1-space"> </span><span class="cpp1-identifier">ratioFreq</span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-symbol">(</span><span class="cpp1-float">255.00</span><span class="cpp1-symbol">)/</span><span class="cpp1-identifier">MAXFREQ</span><span class="cpp1-symbol">;

</span><span class="cpp1-space">	</span><span class="cpp1-reservedword">if</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">adcSpeed</span><span class="cpp1-space"> </span><span class="cpp1-symbol">==</span><span class="cpp1-float">255.00</span><span class="cpp1-symbol">)
</span><span class="cpp1-space">		</span><span class="cpp1-identifier">freq</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-identifier">MAXFREQ</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">	</span><span class="cpp1-reservedword">else
</span><span class="cpp1-space">		</span><span class="cpp1-identifier">freq</span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-symbol">(</span><span class="cpp1-reservedword">double</span><span class="cpp1-symbol">)</span><span class="cpp1-identifier">adcSpeed</span><span class="cpp1-symbol">/</span><span class="cpp1-identifier">ratioFreq</span><span class="cpp1-symbol">;

</span><span class="cpp1-space">	</span><span class="cpp1-reservedword">return</span><span class="cpp1-space"> </span><span class="cpp1-identifier">freq</span><span class="cpp1-symbol">;

}


</span><span class="cpp1-reservedword">void</span><span class="cpp1-space"> </span><span class="cpp1-identifier">sineWave</span><span class="cpp1-symbol">(</span><span class="cpp1-reservedword">double</span><span class="cpp1-space"> </span><span class="cpp1-identifier">frequency</span><span class="cpp1-symbol">)
{</span><span class="cpp1-space">  </span><span class="cpp1-comment">//preconditions : frequency &lt;=43 hz
</span><span class="cpp1-space">  </span><span class="cpp1-reservedword">unsigned</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">short</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">int</span><span class="cpp1-space"> </span><span class="cpp1-identifier">tmr1Prescale</span><span class="cpp1-symbol">=</span><span class="cpp1-number">8</span><span class="cpp1-symbol">;
</span><span class="cpp1-space"> </span><span class="cpp1-comment">//  unsigned int h_value;

</span><span class="cpp1-space">    </span><span class="cpp1-comment">//Calculate TMR1H &amp; TMR1L
</span><span class="cpp1-space">     </span><span class="cpp1-identifier">tPeriod</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-symbol">(</span><span class="cpp1-reservedword">double</span><span class="cpp1-symbol">)</span><span class="cpp1-number">1</span><span class="cpp1-symbol">/</span><span class="cpp1-space"> </span><span class="cpp1-identifier">frequency</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">     </span><span class="cpp1-identifier">tcp</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-identifier">tPeriod</span><span class="cpp1-symbol">/</span><span class="cpp1-space"> </span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">TABLELEN</span><span class="cpp1-symbol">);</span><span class="cpp1-space">         </span><span class="cpp1-comment">//changed TABLELEN -&gt; TABLELEN-1
</span><span class="cpp1-space">     </span><span class="cpp1-identifier">t1Freq</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-symbol">(</span><span class="cpp1-reservedword">double</span><span class="cpp1-symbol">)</span><span class="cpp1-identifier">FOSC</span><span class="cpp1-symbol">/(</span><span class="cpp1-number">4</span><span class="cpp1-symbol">*</span><span class="cpp1-identifier">tmr1Prescale</span><span class="cpp1-symbol">);
</span><span class="cpp1-space">   </span><span class="cpp1-identifier">TIMER1V</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-symbol">(</span><span class="cpp1-number">65535</span><span class="cpp1-symbol">)-(</span><span class="cpp1-identifier">tcp</span><span class="cpp1-symbol">*</span><span class="cpp1-identifier">t1Freq</span><span class="cpp1-symbol">);
</span><span class="cpp1-space">   </span><span class="cpp1-identifier">l_value</span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-symbol">(</span><span class="cpp1-reservedword">unsigned</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">short</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">int</span><span class="cpp1-symbol">)</span><span class="cpp1-identifier">TIMER1V</span><span class="cpp1-space"> </span><span class="cpp1-symbol">&amp;</span><span class="cpp1-space"> </span><span class="cpp1-hexadecimal">0x00FF</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">  </span><span class="cpp1-identifier">h_value</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">TIMER1V</span><span class="cpp1-space"> </span><span class="cpp1-symbol">&amp;</span><span class="cpp1-space"> </span><span class="cpp1-hexadecimal">0xFF00</span><span class="cpp1-symbol">)&gt;&gt;</span><span class="cpp1-number">8</span><span class="cpp1-symbol">;

</span><span class="cpp1-space">  </span><span class="cpp1-comment">//Timer1_SetPeriod((unsigned short int)h_value,l_value);

</span><span class="cpp1-symbol">}



</span><span class="cpp1-reservedword">void</span><span class="cpp1-space"> </span><span class="cpp1-identifier">updateDutyCycle</span><span class="cpp1-symbol">(</span><span class="cpp1-reservedword">unsigned</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">short</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">int</span><span class="cpp1-space"> </span><span class="cpp1-identifier">dir</span><span class="cpp1-symbol">,</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">unsigned</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">short</span><span class="cpp1-space"> </span><span class="cpp1-identifier">freq</span><span class="cpp1-symbol">)
{</span><span class="cpp1-space"> </span><span class="cpp1-comment">//PWMSignal, n_position exists
</span><span class="cpp1-space">  </span><span class="cpp1-reservedword">unsigned</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">short</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">int</span><span class="cpp1-space"> </span><span class="cpp1-identifier">temp</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">  
  </span><span class="cpp1-comment">// Frequency profile
</span><span class="cpp1-space">  </span><span class="cpp1-comment">// if(freq&lt;=3.00)
</span><span class="cpp1-space">		</span><span class="cpp1-comment">// freq =0;
</span><span class="cpp1-space">	</span><span class="cpp1-comment">// else if(freq &lt;=10)
</span><span class="cpp1-space">		</span><span class="cpp1-comment">// factor = getVoltInADC(MINFREQ*ratioVHz,MAXVOLT,bitsVolt)/255.00;
</span><span class="cpp1-space">	</span><span class="cpp1-comment">// else if(freq == 255)
</span><span class="cpp1-space">		</span><span class="cpp1-comment">// factor =1;
</span><span class="cpp1-space">	</span><span class="cpp1-comment">// else
</span><span class="cpp1-space">		</span><span class="cpp1-comment">// factor = getVoltInADC(freq*ratioVHz,MAXVOLT,bitsVolt)/255.00;
</span><span class="cpp1-space">  
  
	</span><span class="cpp1-reservedword">switch</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">dir</span><span class="cpp1-symbol">)
</span><span class="cpp1-space">	</span><span class="cpp1-symbol">{
</span><span class="cpp1-space">			</span><span class="cpp1-reservedword">case</span><span class="cpp1-space"> </span><span class="cpp1-identifier">LEFTDIR</span><span class="cpp1-symbol">:
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">getDutyCycles</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">PWMSignal</span><span class="cpp1-symbol">,</span><span class="cpp1-identifier">n_position</span><span class="cpp1-symbol">);</span><span class="cpp1-space"> </span><span class="cpp1-comment">//Get Dutycycle Values
</span><span class="cpp1-space">        </span><span class="cpp1-identifier">n_position</span><span class="cpp1-symbol">++;
</span><span class="cpp1-space">        </span><span class="cpp1-comment">//getDutyCycles(PWMSignal,9);      // position 9 for testing purposes
</span><span class="cpp1-space">				

				</span><span class="cpp1-identifier">Pwm1_Change_Duty</span><span class="cpp1-symbol">((</span><span class="cpp1-identifier">PWMSignal</span><span class="cpp1-symbol">[</span><span class="cpp1-number">0</span><span class="cpp1-symbol">]*</span><span class="cpp1-identifier">freq</span><span class="cpp1-symbol">)&gt;&gt;</span><span class="cpp1-number">8</span><span class="cpp1-symbol">);
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">Pwm2_Change_Duty</span><span class="cpp1-symbol">((</span><span class="cpp1-identifier">PWMSignal</span><span class="cpp1-symbol">[</span><span class="cpp1-number">1</span><span class="cpp1-symbol">]*</span><span class="cpp1-identifier">freq</span><span class="cpp1-symbol">)&gt;&gt;</span><span class="cpp1-number">8</span><span class="cpp1-symbol">);
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">Pwm3_Change_Duty</span><span class="cpp1-symbol">((</span><span class="cpp1-identifier">PWMSignal</span><span class="cpp1-symbol">[</span><span class="cpp1-number">2</span><span class="cpp1-symbol">]*</span><span class="cpp1-identifier">freq</span><span class="cpp1-symbol">)&gt;&gt;</span><span class="cpp1-number">8</span><span class="cpp1-symbol">);
</span><span class="cpp1-space">			</span><span class="cpp1-reservedword">break</span><span class="cpp1-symbol">;

</span><span class="cpp1-space">			</span><span class="cpp1-reservedword">case</span><span class="cpp1-space"> </span><span class="cpp1-identifier">RIGHTDIR</span><span class="cpp1-symbol">:
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">getDutyCycles</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">PWMSignal</span><span class="cpp1-symbol">,</span><span class="cpp1-identifier">n_position</span><span class="cpp1-symbol">);</span><span class="cpp1-space"> </span><span class="cpp1-comment">//Get Dutycycle Values
</span><span class="cpp1-space">				</span><span class="cpp1-comment">//getDutyCycles(PWMSignal,9);      // position 9 for testing purposes
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">temp</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-identifier">PWMSignal</span><span class="cpp1-symbol">[</span><span class="cpp1-number">0</span><span class="cpp1-symbol">];</span><span class="cpp1-space"> </span><span class="cpp1-comment">//PWM1
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">PWMSignal</span><span class="cpp1-symbol">[</span><span class="cpp1-number">0</span><span class="cpp1-symbol">]</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-identifier">PWMSignal</span><span class="cpp1-symbol">[</span><span class="cpp1-number">1</span><span class="cpp1-symbol">];</span><span class="cpp1-space"> </span><span class="cpp1-comment">//PWM1 = PWM2
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">PWMSignal</span><span class="cpp1-symbol">[</span><span class="cpp1-number">1</span><span class="cpp1-symbol">]</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-identifier">temp</span><span class="cpp1-symbol">;</span><span class="cpp1-space">   </span><span class="cpp1-comment">//PWM2 = PWM1

</span><span class="cpp1-space">				</span><span class="cpp1-identifier">Pwm1_Change_Duty</span><span class="cpp1-symbol">((</span><span class="cpp1-identifier">PWMSignal</span><span class="cpp1-symbol">[</span><span class="cpp1-number">0</span><span class="cpp1-symbol">]*</span><span class="cpp1-identifier">freq</span><span class="cpp1-symbol">)&gt;&gt;</span><span class="cpp1-number">8</span><span class="cpp1-symbol">);
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">Pwm2_Change_Duty</span><span class="cpp1-symbol">((</span><span class="cpp1-identifier">PWMSignal</span><span class="cpp1-symbol">[</span><span class="cpp1-number">1</span><span class="cpp1-symbol">]*</span><span class="cpp1-identifier">freq</span><span class="cpp1-symbol">)&gt;&gt;</span><span class="cpp1-number">8</span><span class="cpp1-symbol">);
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">Pwm3_Change_Duty</span><span class="cpp1-symbol">((</span><span class="cpp1-identifier">PWMSignal</span><span class="cpp1-symbol">[</span><span class="cpp1-number">2</span><span class="cpp1-symbol">]*</span><span class="cpp1-identifier">freq</span><span class="cpp1-symbol">)&gt;&gt;</span><span class="cpp1-number">8</span><span class="cpp1-symbol">);
</span><span class="cpp1-space">			</span><span class="cpp1-reservedword">break</span><span class="cpp1-symbol">;

</span><span class="cpp1-space">			</span><span class="cpp1-reservedword">default</span><span class="cpp1-symbol">:
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">Pwm1_Change_Duty</span><span class="cpp1-symbol">(</span><span class="cpp1-number">0</span><span class="cpp1-symbol">);
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">Pwm2_Change_Duty</span><span class="cpp1-symbol">(</span><span class="cpp1-number">0</span><span class="cpp1-symbol">);
</span><span class="cpp1-space">				</span><span class="cpp1-identifier">Pwm3_Change_Duty</span><span class="cpp1-symbol">(</span><span class="cpp1-number">0</span><span class="cpp1-symbol">);
</span><span class="cpp1-space">			</span><span class="cpp1-reservedword">break</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">	</span><span class="cpp1-symbol">}

}


</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">void</span><span class="cpp1-space"> </span><span class="cpp1-identifier">interrupt</span><span class="cpp1-symbol">()
</span><span class="cpp1-space"> </span><span class="cpp1-symbol">{</span><span class="cpp1-space"> 
   </span><span class="cpp1-comment">//Timer1 Interrupt
</span><span class="cpp1-space">  </span><span class="cpp1-reservedword">if</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">PIR1</span><span class="cpp1-symbol">.</span><span class="cpp1-identifier">TMR1IF</span><span class="cpp1-symbol">)
</span><span class="cpp1-space">  </span><span class="cpp1-symbol">{
</span><span class="cpp1-space">    </span><span class="cpp1-identifier">TESTPIN</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-symbol">~(</span><span class="cpp1-identifier">TESTPIN</span><span class="cpp1-symbol">);

</span><span class="cpp1-space">    </span><span class="cpp1-identifier">TMR1H</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-identifier">h_value</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">	 </span><span class="cpp1-identifier">TMR1L</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-identifier">l_value</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">    </span><span class="cpp1-identifier">PIR1</span><span class="cpp1-symbol">.</span><span class="cpp1-identifier">TMR1IF</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">;</span><span class="cpp1-space"> </span><span class="cpp1-comment">//Clear Flag
</span><span class="cpp1-space">    </span><span class="cpp1-comment">//Disable TMR1 Interrupt
</span><span class="cpp1-space">    </span><span class="cpp1-identifier">PIE1</span><span class="cpp1-symbol">.</span><span class="cpp1-identifier">TMR1IE</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-number">0</span><span class="cpp1-symbol">;</span><span class="cpp1-space"> </span><span class="cpp1-comment">//Disables TMR1 Interrupt

</span><span class="cpp1-space">    </span><span class="cpp1-identifier">tmr1Overflow</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">TRUE</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">  </span><span class="cpp1-symbol">}</span><span class="cpp1-reservedword">else</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">if</span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">INTCON</span><span class="cpp1-symbol">.</span><span class="cpp1-identifier">TMR0IF</span><span class="cpp1-symbol">)
</span><span class="cpp1-space">  </span><span class="cpp1-symbol">{
</span><span class="cpp1-space">      </span><span class="cpp1-identifier">TESTPIN2</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-space"> </span><span class="cpp1-symbol">~(</span><span class="cpp1-identifier">TESTPIN2</span><span class="cpp1-symbol">);

</span><span class="cpp1-space">     </span><span class="cpp1-identifier">TMR0</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">timerValue</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">     </span><span class="cpp1-identifier">INTCON</span><span class="cpp1-symbol">.</span><span class="cpp1-identifier">TMR0IF</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-number">0</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">	 </span><span class="cpp1-identifier">Timer0_ID</span><span class="cpp1-symbol">();
</span><span class="cpp1-space">     </span><span class="cpp1-identifier">tmr0Overflow</span><span class="cpp1-space"> </span><span class="cpp1-symbol">=</span><span class="cpp1-identifier">TRUE</span><span class="cpp1-symbol">;
</span><span class="cpp1-space">  </span><span class="cpp1-symbol">}

</span><span class="cpp1-space"> </span><span class="cpp1-symbol">}




</span></code></pre><!--EndFragment--></body>
</html>